This notebook will generate the cfgs to submit the chains for the final version of the chains for Aemulus.

For rmin 0, 0.5, 1.0, 2.0:

For no ab, HSAB, CAB, and CorrAB emu:

    HOD
    Vpeak sham
    UM
    Shuffled SHAM?

In [4]:
import yaml
import copy
from os import path
import numpy as np

In [5]:
orig_cfg_fname = '/u/ki/swmclau2/Git/pearce/bin/mcmc/nh_gg_sham_hsab_mcmc_config.yaml'
with open(orig_cfg_fname, 'r') as yamlfile:
    orig_cfg = yaml.load(yamlfile)

In [6]:
orig_cfg


Out[6]:
{'chain': {'fixed_params': {},
  'nburn': 0,
  'nsteps': 10000,
  'nwalkers': 500,
  'seed': 0},
 'data': {'cov': {'emu_cov_fname': '/home/users/swmclau2/Git/pearce/bin/covmat/xi_gg_nh_emu_cov.npy',
   'meas_cov_fname': '/home/users/swmclau2/Git/pearce/notebooks/meas_cov_testboxes_gg.npy'},
  'obs': {'mean': False,
   'obs': 'xi',
   'rbins': [0.07943282,
    0.11220185,
    0.15848932,
    0.22387211,
    0.31622777,
    0.44668359,
    0.63095734,
    0.89125094,
    1.25892541,
    1.77827941,
    2.51188643,
    3.54813389,
    5.01187234,
    7.07945784,
    10.0,
    14.12537545,
    19.95262315,
    28.18382931,
    39.81071706]},
  'sim': {'gal_type': 'SHAM',
   'halo_property': 'halo_vpeak',
   'min_ptcl': 100,
   'nd': '5e-4',
   'scale_factor': 1.001,
   'scatter': 0.2,
   'sim_hps': {'system': 'sherlock'},
   'simname': 'ds_14_b_sub'},
  'true_cov_fname': ['/home/users/swmclau2/Git/pearce/bin/shams/xigg_cov_mcmc.npy'],
  'true_data_fname': ['/home/users/swmclau2/Git/pearce/bin/shams/ds14b_sub_xi_gg.npy']},
 'emu': {'emu_hps': {},
  'emu_type': 'NashvilleHot',
  'fixed_params': {'z': 0.0},
  'training_file': '/home/users/swmclau2/scratch/xi_gg_abzheng07/PearceXiggHSABCosmo.hdf5'},
 'fname': '/scratch/users/swmclau2/PearceMCMC/pearce_mcmc_nh_gg_sham_hsab.hdf5'}
orig_sbatch_fname = '/home/users/swmclau2/Git/pearce/bin/mcmc/nh_gg_sham_hsab_mcmc_config.sbatch' with open(orig_sbatch_fname, 'r') as f: lines = [] for line in f: lines.append(line) orig_sbatch = ''.join(lines)
#this will enable easier string formatting sbatch_template = """#!/bin/bash #SBATCH --job-name={jobname} #SBATCH --time=12:00:00 #SBATCH -p kipac #SBATCH -o /home/users/swmclau2/Git/pearce/bin/mcmc/config/{jobname}.out #SBATCH --ntasks=16 ###SBATCH --exclusive module load python/2.7.13 module load py-scipystack module load hdf5/1.10.0p1 module load py-numpy python /home/users/swmclau2/Git/pearce/pearce/inference/initialize_mcmc.py {jobname}.yaml #python /home/users/swmclau2/Git/pearce/pearce/inference/run_mcmc.py {jobname}.yaml """

In [7]:
bsub_template="""#BSUB -q medium 
#BSUB -W 24:00
#BSUB -J {jobname}
#BSUB -oo /u/ki/swmclau2/Git/pearce/bin/mcmc/config/{jobname}.out    
#BSUB -n 8 
#BSUB -R "span[ptile=8]"

python /u/ki/swmclau2/Git/pearce/pearce/inference/initialize_mcmc.py {jobname}.yaml
python /u/ki/swmclau2/Git/pearce/pearce/inference/run_mcmc.py {jobname}.yaml
"""

In [8]:
r_bins = np.logspace(-1, 1.6, 19)
#emu fnames emu_fnames = ['/scratch/users/swmclau2/xi_gg_zheng07_cosmo_v3/PearceXiggCosmo.hdf5', '/scratch/users/swmclau2/xi_gg_hsabzheng07_v2/PearceXiggHSABCosmo.hdf5', '/scratch/users/swmclau2/xi_gg_corrabzheng07_v2/PearceXiggCosmoCorrAB.hdf5'] emu_names = ['HOD', 'HSAB', 'CorrAB']

In [9]:
#emu fnames
#emu_fnames = [#'/nfs/slac/g/ki/ki18/des/swmclau2/xi_gg_zheng07_v4/PearceXiggCosmo.hdf5',\
#              '/nfs/slac/g/ki/ki18/des/swmclau2/xi_gg_hsabzheng07_v2/PearceXiggCosmoCorrAB.hdf5']
emu_fnames = [['/u/ki/swmclau2/des/wp_zheng07/PearceWpCosmo.hdf5', '/u/ki/swmclau2/des/ds_zheng07/PearceDsCosmo.hdf5']]
#emu_cov_fnames = [#'/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/bin/covmat/xi_gg_nh_emu_cov_v4.npy',
#                  '/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/bin/covmat/xi_gg_nh_emu_hsab_cov_v4.npy']
emu_names = ['HOD']
np.save('dummy_emu_covmat.npy', np.zeros((18,18)))

In [10]:
meas_cov_fname = '/u/ki/swmclau2/Git/pearce/bin/covmat/wp_ds_full_covmat.npy'

# TODO replace with actual ones onace test boxes are done 
emu_cov_fnames = [['/u/ki/swmclau2/Git/pearce/bin/optimization/wp_hod_emu_cov.npy', 
                   '/u/ki/swmclau2/Git/pearce/bin/optimization/ds_hod_emu_cov.npy']]
# prep full covs full_covs = [] for emu_name, emu_fname, cov_fname in zip(emu_names, emu_fnames, emu_cov_fnames): cov = np.load(cov_fname) full_cov = cov+meas_cov fname = '/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/notebooks/%s_full_cov.npy'%emu_name np.savetxt(fname, full_cov) full_covs.append(fname)

Vpeak SHAM


tmp_cfg = copy.deepcopy(orig_cfg) directory = "/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/bin/mcmc/config/" output_dir = "/nfs/slac/g/ki/ki18/des/swmclau2/PearceMCMC/" jobname_template = "VpeakSHAM_xi_gg_rmin_{rmin}_{emu_name}_v3" for rmin in [None, 0.5, 1.0]: for emu_fname, emu_name, emu_cov, ecf in zip(emu_fnames, emu_names, full_covs, emu_cov_fnames): if rmin is not None: tmp_cfg['emu']['fixed_params'] = {'z': 0.0, 'rmin':rmin} tmp_cfg['emu']['training_file'] = emu_fname tmp_cfg['data']['true_data_fname']= ['/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/bin/shams/ds14b_sub_xi_gg.npy'] tmp_cfg['data']['true_cov_fname'] = [emu_cov] tmp_cfg['chain']['nsteps'] = 20000 tmp_cfg['chain']['nwalkers'] = 100 tmp_cfg['data']['sim']['sim_hps']['system'] = 'ki-ls' tmp_cfg['data']['cov']['emu_cov_fname'] = ecf #not used, but save anyway tmp_cfg['data']['cov']['meas_cov_fname'] = meas_cov_fname jobname = jobname_template.format(rmin=rmin, emu_name=emu_name) tmp_cfg['fname'] = path.join(output_dir, jobname+'.hdf5') with open(path.join(directory, jobname +'.yaml'), 'w') as f: yaml.dump(tmp_cfg, f) with open(path.join(directory, jobname + '.bsub'), 'w') as f: f.write(bsub_template.format(jobname=jobname))

Mpeak SHAM


tmp_cfg = copy.deepcopy(orig_cfg) directory = "/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/bin/mcmc/config/" output_dir = "/nfs/slac/g/ki/ki18/des/swmclau2/PearceMCMC/" jobname_template = "MpeakSHAM_xi_gg_rmin_{rmin}_{emu_name}_v3" for rmin in [None, 0.5, 1.0, 2.0]: for emu_fname, emu_name, emu_cov in zip(emu_fnames, emu_names, full_covs): if rmin is not None: tmp_cfg['emu']['fixed_params'] = {'z': 0.0, 'rmin':rmin} tmp_cfg['emu']['training_file'] = emu_fname tmp_cfg['data']['true_data_fname']= ['/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/bin/shams/ds14b_sub_mpeak_xi_gg.npy'] tmp_cfg['data']['true_cov_fname'] = [emu_cov] tmp_cfg['chain']['nsteps'] = 20000 tmp_cfg['chain']['nwalkers'] = 100 tmp_cfg['sim']['sim_hps']['system'] = 'ki-ls' tmp_cfg['data']['cov']['emu_cov_fname'] = ecf #not used, but save anyway tmp_cfg['data']['cov']['emu_cov_fname'] = meas_cov_fname jobname = jobname_template.format(rmin=rmin, emu_name=emu_name) tmp_cfg['fname'] = path.join(output_dir, jobname+'.hdf5') with open(path.join(directory, jobname +'.yaml'), 'w') as f: yaml.dump(tmp_cfg, f) with open(path.join(directory, jobname + '.bsub'), 'w') as f: f.write(bsub_template.format(jobname=jobname))

HOD



In [11]:
#orig_cfg_fname = '/u/ki/swmclau2//Git/pearce/bin/mcmc/nh_gg_sham_hsab_mcmc_config.yaml'
with open(orig_cfg_fname, 'r') as yamlfile:
    orig_cfg = yaml.load(yamlfile)

In [12]:
orig_cfg


Out[12]:
{'chain': {'fixed_params': {},
  'nburn': 0,
  'nsteps': 10000,
  'nwalkers': 500,
  'seed': 0},
 'data': {'cov': {'emu_cov_fname': '/home/users/swmclau2/Git/pearce/bin/covmat/xi_gg_nh_emu_cov.npy',
   'meas_cov_fname': '/home/users/swmclau2/Git/pearce/notebooks/meas_cov_testboxes_gg.npy'},
  'obs': {'mean': False,
   'obs': 'xi',
   'rbins': [0.07943282,
    0.11220185,
    0.15848932,
    0.22387211,
    0.31622777,
    0.44668359,
    0.63095734,
    0.89125094,
    1.25892541,
    1.77827941,
    2.51188643,
    3.54813389,
    5.01187234,
    7.07945784,
    10.0,
    14.12537545,
    19.95262315,
    28.18382931,
    39.81071706]},
  'sim': {'gal_type': 'SHAM',
   'halo_property': 'halo_vpeak',
   'min_ptcl': 100,
   'nd': '5e-4',
   'scale_factor': 1.001,
   'scatter': 0.2,
   'sim_hps': {'system': 'sherlock'},
   'simname': 'ds_14_b_sub'},
  'true_cov_fname': ['/home/users/swmclau2/Git/pearce/bin/shams/xigg_cov_mcmc.npy'],
  'true_data_fname': ['/home/users/swmclau2/Git/pearce/bin/shams/ds14b_sub_xi_gg.npy']},
 'emu': {'emu_hps': {},
  'emu_type': 'NashvilleHot',
  'fixed_params': {'z': 0.0},
  'training_file': '/home/users/swmclau2/scratch/xi_gg_abzheng07/PearceXiggHSABCosmo.hdf5'},
 'fname': '/scratch/users/swmclau2/PearceMCMC/pearce_mcmc_nh_gg_sham_hsab.hdf5'}

In [15]:
list(r_bins)


Out[15]:
[0.1,
 0.13945832491957455,
 0.19448624389373625,
 0.27122725793320285,
 0.3782489906389385,
 0.527499706370262,
 0.7356422544596414,
 1.0259143654700102,
 1.430722989193758,
 1.9952623149688797,
 2.782559402207126,
 3.8805107322101837,
 5.411695265464638,
 7.547059566968908,
 10.525002852777337,
 14.677992676220706,
 20.46968271807522,
 28.54667663497933,
 39.810717055349734]

In [14]:
tmp_cfg = copy.deepcopy(orig_cfg)
directory = "/u/ki/swmclau2/Git/pearce/bin/mcmc/config/"
output_dir = "/nfs/slac/g/ki/ki18/des/swmclau2/PearceMCMC/"
#output_dir = "/afs/slac.stanford.edu/u/ki/swmclau2"

jobname_template = "HOD_wp_ds_rmin_{rmin}_{emu_name}"#_fixed_HOD"

for rmin in [None, 0.5, 1.0, 2.0]:
    for emu_fname, emu_name, emu_cov in zip(emu_fnames, emu_names, emu_cov_fnames):
        
        tmp_cfg['chain']['nwalkers'] = 200
        if rmin is not None:
            tmp_cfg['emu']['fixed_params'] = {'z': 0.0, 'rmin':rmin}
            
        tmp_cfg['emu']['training_file'] = emu_fname
        tmp_cfg['emu']['emu_type'] = ['NashvilleHot' for i in xrange(len(emu_fname))]
        tmp_cfg['emu']['emu_cov_fname'] = emu_cov
        
        tmp_cfg['data']['obs']['obs'] = ['wp','ds']
        tmp_cfg['data']['obs']['rbins'] = list(r_bins)
        
        tmp_cfg['data']['cov']['meas_cov_fname'] = meas_cov_fname
        tmp_cfg['data']['cov']['emu_cov_fname'] = tmp_cfg['emu']['emu_cov_fname'] # TODO make this not be redundant
        
        jobname = jobname_template.format(rmin=rmin, emu_name=emu_name)
        tmp_cfg['fname'] = path.join(output_dir, jobname+'.hdf5')
        
        tmp_cfg['sim']= {'gal_type': 'HOD',
       'hod_name': 'zheng07',
       'hod_params': {'alpha': 1.083,
        'logM0': 13.2,
        'logM1': 14.2,
        'sigma_logM': 0.2,
        'conc_gal_bias': 1.0},
       'nd': '5e-4',
       'scale_factor': 1.0,
       'min_ptcl': 100, 
       'sim_hps': {'boxno': 1,
        'downsample_factor': 1e-2,
        'particles': True,
        'realization': 0,
        'system': 'ki-ls'},
       'simname': 'testbox'}
        
        # TODO i shouldnt have to specify this this way
        tmp_cfg['data']['sim'] = tmp_cfg['sim']
        
        
        tmp_cfg['chain']['nsteps'] = 10000
        tmp_cfg['chain']['mcmc_type'] = 'normal'
        
        # fix params during MCMC    
        #tmp_cfg['chain']['fixed_params'].update(tmp_cfg['sim']['hod_params'])
        
        try:
            del tmp_cfg['data']['true_data_fname']
            del tmp_cfg['data']['true_cov_fname']
        except KeyError:
            pass

        with open(path.join(directory, jobname +'.yaml'), 'w') as f:
            yaml.dump(tmp_cfg, f)

        with open(path.join(directory, jobname + '.bsub'), 'w') as f:
            f.write(bsub_template.format(jobname=jobname))

HSAB HOD


tmp_cfg = copy.deepcopy(orig_cfg) directory = "/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/bin/mcmc/config/" output_dir = "/nfs/slac/g/ki/ki18/des/swmclau2/PearceMCMC/" jobname_template = "HSAB_HOD_xi_gg_rmin_{rmin}_{emu_name}_v3" for rmin in [None, 0.5, 1.0, 2.0]: for emu_fname, emu_name, emu_cov in zip(emu_fnames, emu_names, emu_cov_fnames): tmp_cfg['chain']['nwalkers'] = 100 if rmin is not None: tmp_cfg['emu']['fixed_params'] = {'z': 0.0, 'rmin':rmin} tmp_cfg['emu']['training_file'] = emu_fname tmp_cfg['data']['cov']['emu_cov_fname'] = emu_cov tmp_cfg['data']['cov']['emu_cov_fname'] = meas_cov_fname tmp_cfg['sim']= {'gal_type': 'HOD', 'hod_name': 'hsabZheng07', 'hod_params': {'alpha': 1.083, 'logM0': 13.2, 'logM1': 14.2, 'sigma_logM': 0.2, 'mean_occupation_cens_param1':0.6, 'mean_occupation_sats_param1':-0.4}, 'nd': '5e-4', 'scale_factor': 1.0, 'sim_hps': {'boxno': 0, 'downsample_factor': '1e-2', 'particles': False, 'realization': 4, 'system': 'ki-ls'}, 'simname': 'testbox'} tmp_cfg['chain']['nsteps'] = 20000 jobname = jobname_template.format(rmin=rmin, emu_name=emu_name) tmp_cfg['fname'] = path.join(output_dir, jobname+'.hdf5') with open(path.join(directory, jobname +'.yaml'), 'w') as f: yaml.dump(tmp_cfg, f) with open(path.join(directory, jobname + '.bsub'), 'w') as f: f.write(bsub_template.format(jobname=jobname))

In [ ]: